import random
fp = open("./7-深度学习基本原理-三好学生案例/sanhao.txt","w",encoding="utf-8")
def write_sanhao(inputs:list):

    weights =  [0.8 , 0.18, 0.02] # 作业要求的权重值
    # 生成随机数
    # random_number = random.randint(0, 100)
    # 写入文件
    # fp.write(str(random_number) + "\n")
    assert len(inputs) == len(weights), "输入特征数和权重数必须相等"
    return sum([inputs[i] * weights[i] for i in range(len(inputs))])

for i in range(1000):
    x1 = random.randint(30, 100)
    x2 = random.randint(30, 100)
    x3 = random.randint(30, 100)
    inputs = [x1, x2, x3]
    # score = write_sanhao(inputs)
    # 加权和分数，保留整数部分
    score = write_sanhao(inputs)
    fp.write(f"{x1} {x2} {x3} {score:.0f}\n")
fp.close()